import java.util.ArrayList;
import java.util.Random;

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;


public class SystemPanel extends JPanel{
	
	private JLabel lblDistance;
	private JLabel lblTechLevel;
	private JLabel lblSizeTiny;
	private JLabel lblPirates;
	private JLabel lblPolice;
	private JLabel lblGovernment;
	private JLabel lblResource;
	private JLabel lblSolarSystem;
	private JLabel lblCurrentSolarSystem;
	private JLabel lblSize;
	private JLabel lblFuelLevel;
	private JLabel lblEvent;
	private String type;
	
	/*
	 * This can only be a constructor for the Target System Info.
	 */
	public SystemPanel(String type){
		//setLayout(new GridLayout(8,1));
		this.type =type;
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
		lblCurrentSolarSystem = new JLabel(type + " Solar System:");
		add(lblCurrentSolarSystem);
		
		lblResource = new JLabel("Resource: ");
		add(lblResource);
		
		lblGovernment = new JLabel("Government: ");
		add(lblGovernment);
		
		lblPolice = new JLabel("Police: ");
		add(lblPolice);
		
		lblPirates = new JLabel("Pirates: ");
		add(lblPirates);
		
		lblTechLevel = new JLabel("Tech Level: ");
		add(lblTechLevel);

		lblSize = new JLabel("Size:");
		add(lblSize);
		
		if (type.equals("Target")){
			lblDistance = new JLabel("Distance: ");
			add(lblDistance);
		}
		else{
			lblEvent = new JLabel("Event: ");
			add(lblEvent);
		}
		//need fuel level elsewhere 
	}
	/*
	 * This can only be a constructor for the Current System Info.
	 */
	public SystemPanel(String type, SolarSystem system){ 
		this(type);
		update(system);
		
	}
	
	/*
	 * Call whenever systems
	 * info needs to be changed
	 * 
	 * @param currentSystem a SolarSystem
	 * @param marketplace a Marketplace to get events
	 */
	public void update(SolarSystem system){
		lblCurrentSolarSystem.setText(type + " Solar System: " + system.getName());
		lblResource.setText("Resource: " + system.getResource());
		lblGovernment.setText("Government: " + system.getGovernment());
		lblTechLevel.setText("Tech Level: " + system.getTechLevelName());
		lblSize.setText("Size: " + system.getSize());
		if (type.equals("Target")){
			lblDistance.setText("Distance: " + system.getDistance(system));
		}
	}
	
	/*
	 * Overloading. Will only be called by tarSystem
	 * 
	 * @param currentSystem a SolarSystem
	 * @param targetSystem a SolarSystem
	 */
	public void update(SolarSystem currSystem, SolarSystem tarSystem){
		update(tarSystem);
		lblDistance.setText("Distance: " + currSystem.getDistance(tarSystem));	
	}
	
	/*
	 * Clears system panel. Will only be called by target system.
	 * 
	 */
	public void clear(){
		lblCurrentSolarSystem.setText(type + " Solar System: " );
		lblResource.setText("Resource: ");
		lblGovernment.setText("Government: ");
		lblTechLevel.setText("Tech Level: ");
		lblSize.setText("Size: ");
		if (type.equals("Target")){
			lblDistance.setText("Distance: ");
		}		
	}
	
	public void setEvent(String event){
		lblEvent.setText("Event: " + event);
	}
}
